#coding: utf-8
class CulturalHeritage::MyHeritageXTransfer < ActiveRecord::Base
  default_scope where("cultural_heritage_my_heritage_x_transfers.deleted = 0")
  belongs_to :obj_transfer, :class_name => 'CulturalHeritage::Transfer', :foreign_key => 'transfer'
  belongs_to :obj_cultural_heritage, :class_name => 'CulturalHeritage::CulturalHeritage', :foreign_key => 'heritage'

  def self.count_cultural_heritage_dependencies(id)
      return find(:all,:conditions=>["cultural_heritage_my_heritage_x_transfers.heritage = ? and (cultural_heritage_my_heritage_x_transfers.deleted = ?) ",id,0],:select=>"count(*) as 'my_heritage_x_transfers'")[0].my_heritage_x_transfers.to_i
  end

  def self.count_transfer_dependencies(id)
      return find(:all,:conditions=>["cultural_heritage_my_heritage_x_transfers.transfer = ? and (cultural_heritage_my_heritage_x_transfers.deleted = ?) ",id,0],:select=>"count(*) as 'my_heritage_x_transfers'")[0].my_heritage_x_transfers.to_i
  end
end
